<template>
  <div id="page">
    <div class="top_box">
      <div class="top flex-grow-1 flex-x-center flex-y-center">
        <div>
          <p>本月预估(元)</p>
          <p>{{profitData.currentMonthIncome}}</p>
        </div>
      </div>
      <div class="bottom flex-row">
        <div class="bottom_left flex-grow-1">
          <p>累计收益(元)</p>
          <p class="comm">{{profitData.totalIncome}}</p>
        </div>
        <div class="bottom_right flex-grow-1">
          <p>上月收益(元)</p>
          <p class="comm">{{profitData.preMonthIncome}}</p>
        </div>
      </div>
    </div>
    <div class="tixian flex-row flex-y-center">
      <div class="left flex-grow-1">
        <div class="yu_e">
          <p>可提现金额(元)</p>
          <p>{{profitData.canTixianMoney}}</p>
        </div>
      </div>
      <div class="right flex-grow-1 ">
        <div @click="tixianbtn" class="btn flex-grow-0">
          提现
        </div>
      </div>
    </div>
    <div class="jianxi"></div>
    <div class="bottom">
      <img v-src="'/static/img/my/profit_03.png'" alt="">
    </div>
  </div>
</template>
<script>
  import {GETPROFIT,POSTTIXIAN} from 'src/const/uri'
  export default{

    data(){
      return {
        profitData:[],
      }
    },
    created(){

    },
    mounted(){
      let spinner = document.getElementsByClassName('spinner')[0];
      spinner.style.display = 'none';
      this.initData();
    },
    methods:{
      initData(){
        this.$ajax.get(GETPROFIT,{},(res)=>{
          this.profitData=res.data;
          console.log(res)
        });
      },
      /*下拉刷新*/
      refreshData(responseCallback) {
        this.initData();
        responseCallback({code: '0'});
      },
      tixianbtn(){
        this.$ajax.post(POSTTIXIAN,{},(res)=>{
          if(res.data.result=='0'){
            this.$vux.confirm.show({
              title: '提示',
              content:`${res.data.message}`,
              confirmText:'成为合伙人',
              onCancel () {
               // WebViewJavascriptBridge.callHandler('doBack');
              },
              onConfirm (msg) {
                let beforeUrl = document.URL.replace(/profit/g, "becomePartner").split('?')[0];
                if (window.WebViewJavascriptBridge) {
                  window.WebViewJavascriptBridge.callHandler('jumpTo', beforeUrl)
                }
              }
            });
          }else if(res.data.result=='1'){
            let beforeUrl = document.URL.replace(/profit/g, "tixian_record").split('?')[0];
            if (window.WebViewJavascriptBridge) {
              window.WebViewJavascriptBridge.callHandler('jumpTo', beforeUrl);
            } else if (isDebug) {
              window.location.href = beforeUrl;
            }
          }else if(res.data.result=='3'){
            this.$vux.confirm.show({
              title: '提示',
              content:`${res.data.message}`,
              onCancel () {
                // WebViewJavascriptBridge.callHandler('doBack');
              },
              onConfirm (msg) {
              }
            });
          }
        });
      }
    }
  }
</script>
<style lang="less" scoped>
  @import "index";
</style>
